package com.ruoyi.amuse.application.controller;


import com.ruoyi.amuse.application.domain.ClubApplication;
import com.ruoyi.amuse.application.service.IClubApplicationService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 团员审批Controller
 * 
 * @author juwujie
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/application/application")
public class ClubApplicationController extends BaseController
{
    @Autowired
    private IClubApplicationService clubApplicationService;

    /**
     * 查询团员审批列表
     */
    @RequiresPermissions("application:application:list")
    @GetMapping("/list")
    public TableDataInfo list(ClubApplication clubApplication)
    {
        startPage();
        List<ClubApplication> list = clubApplicationService.selectClubApplicationList(clubApplication);
        return getDataTable(list);
    }

    /**
     * 导出团员审批列表
     */
    @RequiresPermissions("application:application:export")
    @Log(title = "团员审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClubApplication clubApplication)
    {
        List<ClubApplication> list = clubApplicationService.selectClubApplicationList(clubApplication);
        ExcelUtil<ClubApplication> util = new ExcelUtil<ClubApplication>(ClubApplication.class);
        util.exportExcel(response, list, "团员审批数据");
    }

    /**
     * 获取团员审批详细信息
     */
    @RequiresPermissions("application:application:query")
    @GetMapping(value = "/{applicationId}")
    public AjaxResult getInfo(@PathVariable("applicationId") Long applicationId)
    {
        return success(clubApplicationService.selectClubApplicationByApplicationId(applicationId));
    }

    /**
     * 新增团员审批
     */
    @RequiresPermissions("application:application:add")
    @Log(title = "团员审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClubApplication clubApplication)
    {
        return toAjax(clubApplicationService.insertClubApplication(clubApplication));
    }

    /**
     * 修改团员审批
     */
    @RequiresPermissions("application:application:edit")
    @Log(title = "团员审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClubApplication clubApplication)
    {
        return toAjax(clubApplicationService.updateClubApplication(clubApplication));
    }

    /**
     * 删除团员审批
     */
    @RequiresPermissions("application:application:remove")
    @Log(title = "团员审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applicationIds}")
    public AjaxResult remove(@PathVariable Long[] applicationIds)
    {
        return toAjax(clubApplicationService.deleteClubApplicationByApplicationIds(applicationIds));
    }
}
